import qs from "qs";

export function getProductsByName(name) {
    return new Promise(resolve => {
        axios.post("/product/getProductsByName", qs.stringify({name: name})).then(resp => {
            resolve(resp.data);
        }).catch(() => resolve({code: 204, message: '服务器连接失败'}));
    });
}

export function getProductCount() {
    return new Promise(resolve => {
        axios.post("/product/getProductCount").then(rs => {
            resolve(rs.data);
        })
    })
}

export function getProducts(form) {
    return new Promise(resolve => {
        axios.post("/product/getProducts", qs.stringify(form)).then(resp => {
            resolve(resp.data);
        })
    })
}

export function modifyProductInfo(product) {
    return new Promise(resolve => {
        axios.post("/product/modifyProductInfo", product).then(resp => {
            resolve(resp.data);
        });
    })
}


